(function($){
	$(window).load(function(){
		//footer

		_height = $('.fixed-footer').outerHeight();
		$('.fixed-footer').animate({bottom:'-'+_height},500);

		$('.show_r, .contact-us').click(function(){
			el = $('.show_r, .show_w');
			if(el.hasClass('hide') && el.hasClass('show_w')){
				$('.fixed-footer').stop().animate({bottom:'-383'},500,function(){
					el.removeClass('hide');
					el.removeClass('show_w');
					el.addClass('show_r');
				});
			}else{
				el.addClass('hide');
				el.removeClass('show_r');
				el.addClass('show_w');
				$('.fixed-footer').stop().animate({bottom:0},500);
			}
			
		});
	});

})(jQuery);

$(function() {
	$(document).on('focusin', '.field, textarea', function() {
		if(this.title==this.value) {
			this.value = '';
		}
	}).on('focusout', '.field, textarea', function(){
		if(this.value=='') {
			this.value = this.title;
		}
	});

	$('#navigation ul li:first-child').addClass('first');
	$('.footer-nav ul li:first-child').addClass('first');

	$('#navigation a.nav-btn').click(function(){
		$(this).closest('#navigation').find('ul').slideToggle()
		$(this).find('span').toggleClass('active')
		return false;
	})
});

$(window).load(function() {
	$('.flexslider').flexslider({
		animation: "slide",
		controlsContainer: ".slider-holder",
		slideshowSpeed: 5000,
		directionNav: false,
		controlNav: true,
		animationDuration: 2000,
		before:function( slider ){
			$('.img-holder').animate({'bottom' : '-30px'},300)
		},

		after:function( slider ){
			$('.img-holder').animate({'bottom' : '0px'},300)
		}
	});
});

//Slide text
(function($){
	$(window).ready(function(){
		$('.say').css({
			'width':$('.sayings-beautiful .slides_container').width(),
		})

		$('.sayings-beautiful').slides({
			effect:'fade',
			generatePagination: false,
			play:10000,
			pause:1,
			autoHeight:true
		})

	});
})(jQuery);

//Translate
$(window).ready(function(){
	TranslateThis();
	setupPrettyPhoto();
});

//setup pretty-photo
function setupPrettyPhoto() {

    $("a[rel^='prettyPhoto']").prettyPhoto();
}

//facebook
(function (d, s, id) {
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) return;
	js = d.createElement(s); js.id = id;
	js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1";
	fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

//back to top
function checkSH(time) {
if ($(window).scrollTop() == 0) {
	$('#go_top').stop(false, true).fadeOut(time);
} else {
	$('#go_top').stop(false, true).fadeIn(time);
}
}

$(document).ready(function () {
checkSH(0);
$(window).scroll(function () {
	checkSH(600);
});

$("#go_top").click(function () {
	$('html, body').animate({ scrollTop: 0 }, 'slow');
});
});